import { GET, POST, PUT } from './request'
import type { PageReq, PageRes } from './types'

export interface UserItem {
  id: number
  name: string
  email: string
}

// 登录
export const login = (params: { username: string; password: string }) =>
  POST<{ token: string }>('/user/login', params)

// 获取用户分页
export const getUserPage = (params: PageReq) =>
  GET<PageRes<UserItem>>('/user/page', params)

// 修改用户
export const updateUser = (id: number, data: Partial<UserItem>) =>
  PUT(`/user/${id}`, data)